From 62113d007a6a18668cdcbb52811a1b79630f5848 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Sun, 14 Dec 2025 13:04:56 +0100 Subject: [PATCH] config: allow minimum PD len up to 64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current limit of [1,62] doesn't really seem to be justified. With things like RFC9762 (DHCPv6-PD preferred), it isn't unlikely that we'll see more DHCPv6-PD requests in the future, and not just from actual routers. The smallest realistic PD that can be allocated is a /64, so make that the minimum. Also, fix a bug in the logic (note that the PD_MIN_LEN_MAX actually isn't enforced). Closes: #352 Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcpd/pull/357 Signed-off-by: Álvaro Fernández Rojas --- README.md | 2 +- src/config.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 869d275..97717d2 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ and may also receive information from ubus | dhcpv6_na |bool | 1 | DHCPv6 stateful addressing hands out IA_NA - Internet Address - Network Address | | dhcpv6_pd |bool | 1 | DHCPv6 stateful addressing hands out IA_PD - Internet Address - Prefix Delegation (PD) | | dhcpv6_pd_preferred |bool | 0 | Set the DHCPv6-PD Preferred (P) flag in outgoing ICMPv6 RA message PIOs (RFC9762); requires `dhcpv6` and `dhcpv6_pd`. | -| dhcpv6_pd_min_len |integer| - | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length). Range [1,62] | +| dhcpv6_pd_min_len |integer| - | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length). Range [1,64] | | router |list |``| IPv4 addresses of routers on a given subnet (provided via DHCPv4, should be in order of preference) | | dns |list |``| DNS servers to announce, accepts IPv4 and IPv6 | | dnr |list |disabled| Encrypted DNS servers to announce, ` [ ...]` | diff --git a/src/config.c b/src/config.c index cb971fd..6948b0f 100644 --- a/src/config.c +++ b/src/config.c @@ -69,7 +69,7 @@ struct sys_conf sys_conf = { #define HOSTID_LEN_MAX 64 #define HOSTID_LEN_DEFAULT HOSTID_LEN_MIN -#define PD_MIN_LEN_MAX (64-2) // must delegate at least 2 bits of prefix +#define PD_MIN_LEN_MAX 64 #define OAF_DHCPV6 (OAF_DHCPV6_NA | OAF_DHCPV6_PD) @@ -1456,12 +1456,14 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_DHCPV6_PD_MIN_LEN])) { uint32_t pd_min_len = blobmsg_get_u32(c); - if (pd_min_len > PD_MIN_LEN_MAX) - iface->dhcpv6_pd_min_len = PD_MIN_LEN_MAX; - iface->dhcpv6_pd_min_len = pd_min_len; - if (pd_min_len > PD_MIN_LEN_MAX) + + if (pd_min_len > PD_MIN_LEN_MAX) { + pd_min_len = PD_MIN_LEN_MAX; warn("Clamped invalid %s value configured for interface '%s' to %d", - iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, iface->dhcpv6_pd_min_len); + iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, pd_min_len); + } + + iface->dhcpv6_pd_min_len = pd_min_len; } if ((c = tb[IFACE_ATTR_DHCPV6_NA])) -- 2.30.2